/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package boundless.entities;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author hendrikdekock
 */
@Entity
@Table(name = "PLAYERTEAM")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Playerteam.findAll", query = "SELECT p FROM Playerteam p"),
    @NamedQuery(name = "Playerteam.findByPlayerid", query = "SELECT p FROM Playerteam p WHERE p.playerteamPK.playerid = :playerid"),
    @NamedQuery(name = "Playerteam.findByTeamid", query = "SELECT p FROM Playerteam p WHERE p.playerteamPK.teamid = :teamid"),
    @NamedQuery(name = "Playerteam.findByActive", query = "SELECT p FROM Playerteam p WHERE p.active = :active")})
public class Playerteam implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected PlayerteamPK playerteamPK;
    @Basic(optional = false)
    @NotNull
    @Column(name = "ACTIVE")
    private short active;
    @JoinColumn(name = "PLAYERID", referencedColumnName = "ID", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Player player;
    @JoinColumn(name = "LEAGUEID", referencedColumnName = "ID")
    @ManyToOne(optional = false)
    private League leagueid;
    @JoinColumn(name = "TEAMID", referencedColumnName = "ID", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Fantasyteams fantasyteams;

    public Playerteam() {
    }

    public Playerteam(PlayerteamPK playerteamPK) {
        this.playerteamPK = playerteamPK;
    }

    public Playerteam(PlayerteamPK playerteamPK, short active) {
        this.playerteamPK = playerteamPK;
        this.active = active;
    }

    public Playerteam(int playerid, int teamid) {
        this.playerteamPK = new PlayerteamPK(playerid, teamid);
    }
    
    public Playerteam(int playerid, int teamid, League l, short active) {
        this.playerteamPK = new PlayerteamPK(playerid, teamid);
        this.leagueid = l;
        this.active = active;
    }

    public PlayerteamPK getPlayerteamPK() {
        return playerteamPK;
    }

    public void setPlayerteamPK(PlayerteamPK playerteamPK) {
        this.playerteamPK = playerteamPK;
    }

    public short getActive() {
        return active;
    }

    public void setActive(short active) {
        this.active = active;
    }

    public Player getPlayer() {
        return player;
    }

    public void setPlayer(Player player) {
        this.player = player;
    }

    public League getLeagueid() {
        return leagueid;
    }

    public void setLeagueid(League leagueid) {
        this.leagueid = leagueid;
    }

    public Fantasyteams getFantasyteams() {
        return fantasyteams;
    }

    public void setFantasyteams(Fantasyteams fantasyteams) {
        this.fantasyteams = fantasyteams;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (playerteamPK != null ? playerteamPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Playerteam)) {
            return false;
        }
        Playerteam other = (Playerteam) object;
        if ((this.playerteamPK == null && other.playerteamPK != null) || (this.playerteamPK != null && !this.playerteamPK.equals(other.playerteamPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "boundless.entities.Playerteam[ playerteamPK=" + playerteamPK + " ]";
    }
    
}
